import os

#设置虚拟网卡
strcmd = 'ifconfig eth0:0 192.168.50.101 netmask 255.255.255.0 up'
with os.popen(strcmd) as f:
    print(f'exec {strcmd} ret is {f.readlines()}')

strcmd = 'iptables -t nat -D POSTROUTING -o tun0 --source 192.168.50.0/24 -j MASQUERADE'
with os.popen(strcmd) as f:
    print(f'exec {strcmd} ret is {f.readlines()}')
strcmd = 'iptables -t nat -A POSTROUTING -o tun0 --source 192.168.50.0/24 -j MASQUERADE'
with os.popen(strcmd) as f:
    print(f'exec {strcmd} ret is {f.readlines()}')


print(f'init task over')